copy USB_APP\USB_APP.hex .\output.hex

hex2bin output.hex

for /f %%i in ('dir /b output.bin') do (
  set indexdx=%%~zi
)
ECHO %indexdx%

srec_cat.exe output.bin -Binary -crop 0 %indexdx% -STM32_LittleEndian %indexdx% -o app.bin -Binary
@REM 将indexdx加上8，是因为app.bin文件头有文件长度4字节，CRC有4字节，所以要加上8
@REM set /a indexdx=indexdx+8
@REM ECHO %indexdx%
@REM 成功将长度数据写在bin文件开头
@REM srec_cat.exe -generate 0x00 0x04 -constant-l-e %indexdx% 4 app.bin -Binary -offset 0x04 -o app2.bin -Binary
@REM srec_cat.exe -generate 0x00 0x04 -constant-l-e %indexdx% 4 -o test.bin -Binary
@REM srec_cat.exe test.bin -Binary app.bin -Binary -offset 0x04 -o app2.bin -Binary